/*
 * @Author: Joel
 * @Date: 2025-04-16 13:09:41
 * @LastEditors: Joel
 * @LastEditTime: 2025-04-16 18:22:32
 * @FilePath: /gd32f303cct6/usr/board_driver/oled_icon.c
 * @Description: 
 * Copyright (C) 2025 YiJiaLink, All Rights Reserved. 
 * 2025-04-16 13:09:41
 */

#include"oled_icon.h"
#include "battery_icon.h"
#include "pump_icon.h"
#include "temp_icon.h"
#include "alarm_icon.h"
#include "light_icon.h"
#include "number_icon.h"
#include "oled.h"

void set_battery_icon(enum BAT_STATE BAT_STATE)
{
    struct oled_func *oled_set;
    oled_set = oled_driver_init();
    switch (BAT_STATE)
    {
    case BAT_EMPY:
    oled_set->draw_bmp(0,0,20,24,battery_empy);
    BAT_STATE++;
    break;
    case BAT_LOW :
    oled_set->draw_bmp(0,0,20,24,battery_low);
    BAT_STATE++;
    break;
    case BAT_QUAR:
    oled_set->draw_bmp(0,0,20,24,battery_quarter);
    BAT_STATE++;
    break;
    case BAT_HALF:
    oled_set->draw_bmp(0,0,20,24,battery_half);
    BAT_STATE++;
    break;
    case BAT_THR_QUAR:
    oled_set->draw_bmp(0,0,20,24,battery_three_quarters);
    BAT_STATE++;
    break;
    case BAT_FULL:
    oled_set->draw_bmp(0,0,20,24,battery_full);
    BAT_STATE++;
    break;
    default:
    oled_set->draw_clear(0,0,20,24,0x00);
    BAT_STATE=BAT_EMPY;
        break;
    }
    return;
}
void set_pump_icon(enum PUMP_STATE PUMP_STATE)
{
    struct oled_func *oled_set;
    oled_set = oled_driver_init();
    switch (PUMP_STATE)
        {
        case PUMP_OFF:
        oled_set->draw_bmp(21,0,20,24,pump_level0);
        PUMP_STATE++;
        break;
        case PUMP_LEVEL1 :
        oled_set->draw_bmp(21,0,20,24,pump_level1);
        PUMP_STATE++;
        break;
        case PUMP_LEVEL2:
        oled_set->draw_bmp(21,0,20,24,pump_level2);
        PUMP_STATE++;
        break;
        case PUMP_LEVEL3:
        oled_set->draw_bmp(21,0,20,24,pump_level3);
        PUMP_STATE++;
        break;
        default:
        oled_set->draw_clear(21,0,20,24,0x00);
        PUMP_STATE=PUMP_OFF;
            break;
        }
        return;
}
void set_temp_icon(enum TEMP_STATE TEMP_STATE)
{
    struct oled_func *oled_set;
    oled_set = oled_driver_init();
    switch (TEMP_STATE)
    {
    case TEMP_OFF:
        oled_set->draw_bmp(42, 0, 20, 24, temp0);
        TEMP_STATE++;
        break;
    case TEMP_LEVEL1:
        oled_set->draw_bmp(42, 0, 20, 24, temp1);
        TEMP_STATE++;
        break;
    case TEMP_LEVEL2:
        oled_set->draw_bmp(42, 0, 20, 24, temp2);
        TEMP_STATE++;
        break;
    case TEMP_LEVEL3:
        oled_set->draw_bmp(42, 0, 20, 24, temp3);
        TEMP_STATE++;
        break;
    default:
        oled_set->draw_clear(42, 0, 20, 24, 0x00);
        TEMP_STATE = TEMP_OFF;
        break;
    }
    return;
}
void set_alarm_icon(enum ALARM_STATE ALARM_STATE)
{
    struct oled_func *oled_set;
    oled_set = oled_driver_init();
    if(ALARM_ON == ALARM_STATE )
    oled_set->draw_bmp(0, 24, 20, 24, alarm);
    else
    oled_set->draw_clear(0, 24, 20, 24, 0x00);
    return;
}
void set_light_icon(enum LIGHT_STATE LIGHT_STATE)
{
    struct oled_func *oled_set;
    oled_set = oled_driver_init();
    
    switch (LIGHT_STATE)
    {
    case LIGHT_OFF:
        oled_set->draw_bmp(42, 24, 20, 24, light_off);
        LIGHT_STATE++;
        break;
    case LIGHT_LEVEL1:
        oled_set->draw_bmp(42, 24, 20, 24, light_level1);
        LIGHT_STATE++;
        break;
    case LIGHT_LEVEL2:
        oled_set->draw_bmp(42, 24, 20, 24, light_level2);
        LIGHT_STATE++;
        break;
    case LIGHT_LEVEL3:
        oled_set->draw_bmp(42, 24, 20, 24, light_level3);
        LIGHT_STATE++;
        break;
    default:
        oled_set->draw_clear(42, 24, 20, 24, 0x00);
        LIGHT_STATE = LIGHT_OFF;
        break;
    }
    return;
}
void set_num_icon(enum NUM_STATE NUM_STATE)
{
    struct oled_func *oled_set;
    oled_set = oled_driver_init();
    
    switch (NUM_STATE)
    {
    case NUM_0:
        oled_set->draw_bmp(21, 24, 20, 24, num_0);
        NUM_STATE++;
        break;
    case NUM_1:
        oled_set->draw_bmp(21, 24, 20, 24, num_1);
        NUM_STATE++;
        break;
    case NUM_2:
        oled_set->draw_bmp(21, 24, 20, 24, num_2);
        NUM_STATE++;
        break;
    case NUM_3:
        oled_set->draw_bmp(21, 24, 20, 24, num_3);
        NUM_STATE++;
        break;
        case NUM_4:
        oled_set->draw_bmp(21, 24, 20, 24, num_4);
        NUM_STATE++;
        break;
        case NUM_5:
        oled_set->draw_bmp(21, 24, 20, 24, num_5);
        NUM_STATE++;
        break;
        case NUM_6:
        oled_set->draw_bmp(21, 24, 20, 24, num_6);
        NUM_STATE++;
        break;
        case NUM_7:
        oled_set->draw_bmp(21, 24, 20, 24, num_7);
        NUM_STATE++;
        break;
        case NUM_8:
        oled_set->draw_bmp(21, 24, 20, 24, num_8);
        NUM_STATE++;
        break;
        case NUM_9:
        oled_set->draw_bmp(21, 24, 20, 24, num_9);
        NUM_STATE++;
        break;
    default:
        oled_set->draw_clear(21, 24, 20, 24, 0x00);
        NUM_STATE = NUM_0;
        break;
    }
    return;
}